package com.songlanyun.modules.rights.service;

import com.songlanyun.common.drive.IBaseService;
import com.songlanyun.common.enums.RightsOrderConstant;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;
import com.songlanyun.modules.order.entity.Order;
import com.songlanyun.modules.order.model.vo.UserOrderRightsSlimStatisticsVo;
import com.songlanyun.modules.payrefund.entity.PayRefundOrder;
import com.songlanyun.modules.rights.entity.RightsOrder;
import com.songlanyun.modules.rights.entity.RightsOrderShipRecord;
import com.songlanyun.modules.rights.model.dto.ApplyOrderRightsDTO;
import com.songlanyun.modules.rights.model.dto.RightsInStockDTO;
import com.songlanyun.modules.rights.model.dto.RightsOrderOperateDTO;
import com.songlanyun.modules.rights.model.dto.RightsOrderShipDTO;
import com.songlanyun.modules.rights.model.vo.RightsMoneyVo;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 销售系统中的维权单（前期可能只做统一维权，不过这样不好）
 *
 * @author lubo
 * @email sunlightcs@gmail.com
 * @date 2020-11-23 13:45:42
 */
public interface RightsOrderService extends IBaseService<Long, RightsOrder> {

    PageUtils queryPage(Map<String, Object> params);

    RightsOrder loadMainRightsOrder(Long userId, Long orderId, boolean tw);

    RightsOrder loadChildRightsOrder(Long userId, Long orderId, Long childOrderId, boolean tw);

    RightsOrder loadByUserAndId(Long userId, Long id, boolean tw);

    RightsOrder applyOrder(ApplyOrderRightsDTO dto);

    RightsOrder applyChildOrder(ApplyOrderRightsDTO dto);

    RightsOrder ship(Long userId, RightsOrderShipDTO dto);

    RightsOrder cancel(Long userId, Long rightsId);

    void autoCancel(RightsOrder rightsOrder);

    RightsOrder loadByShopIdAndId(Long shopId, Long id, boolean tw);

    RightsOrder loadById(Long id, boolean tw);

    RightsOrder agree(Long shopId, RightsOrderOperateDTO dto);

    RightsOrder autoAgree(RightsOrder rightsOrder);

    RightsOrder refuse(Long shopId, RightsOrderOperateDTO dto);

    RightsOrder receipt(Long shopId, RightsOrderOperateDTO dto);

    void autoReceipt(RightsOrder rightsOrder);


    PayRefundOrder refund(Long shopId, RightsOrderOperateDTO dto);
    PayRefundOrder thirdRefund(Long afterSaleId);
    RightsOrder inStock(Long shopId, RightsInStockDTO dto);

    RightsOrder loadByPayRefundOrderId(Long payRefundOrderId, boolean tw);

    RightsOrder refundSuccessOperate(RightsOrder rightsOrder);

    List<RightsOrder> needAutoAgree();

    List<RightsOrder> needAutoCancelRights();

    List<RightsOrder> needAutoReceiptRights();


    PayRefundOrder systemAutoRefund(Order order, RightsOrderConstant.RightsOperatePerson rightsOperatePerson);

    PayRefundOrder shopServiceOrderRefund(Long shopId, ApplyOrderRightsDTO dto);

    PayRefundOrder shopLaunchRefund(Long shopId, Long orderId);

    RightsMoneyVo getMoneyByMainRights(Long userId, Long orderId);

    RightsMoneyVo getMoneyByChildRights(ApplyOrderRightsDTO dto);

    RightsOrderShipRecord expressSelect(Long rightsId);

    UserOrderRightsSlimStatisticsVo loadOrderRightsSlimStatistics(Long shopId, Long userId);

    /**
     * 统计维权订单数
     *
     * @param shopId
     * @param status 0待处理，1待收货，2待退款，3退款完成
     * @return
     */
    Integer loadRightsOrderNum(Long shopId, Integer status);

    RightsOrder loadByThirdRightsId(Long afterSaleId);

    R kqRefund();
}

